#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

void zzzsmithycardplay(int i, int player_no, int handPos,
		struct gameState* state);

void testSmithy(){
	int count;
	while(1){

		struct gameState * game = newGame();
		int cards[10] = {adventurer, gardens, embargo, village, minion, mine, ambassador,
			sea_hag, tribute, smithy};
		int players = 2 + rand()%3;				//game between 2 players and max 4
		initializeGame(players, cards, rand(), game);
		int player_no = rand()%players;
		int handCount = rand()%MAX_HAND;
		int position = rand()%(handCount + 1);
		int i;
		game->deckCount[player_no] = rand()%(MAX_DECK - handCount);
		game->handCount[player_no] = handCount;
		game->discardCount[player_no] = MAX_DECK - game->deckCount[player_no];

		for (i = 0; i < game->deckCount[player_no]; i++){
			game->deck[player_no][i] = rand()%26;
		}
		for (i = 0; i < game->handCount[player_no]; i++){
			game->hand[player_no][i] = rand()%26;
		}
		for (i = 0; i < game->discardCount[player_no]; i++){
			game->discard[player_no][i] = rand()%26;
		}
		zzzsmithycardplay(i, player_no, position, game);

		if ((game->handCount[player_no] == handCount + 2) &&
				(game->hand[player_no][game->handCount[player_no] - 1] == 14) &&
				(game->hand[player_no][game->handCount[player_no] -2] == 14)){
			printf("%d FAIL \n", count);
			break;
		}else{
			printf("%d PASS \n", count);
		}
		count++;
	}
}

int main(){
	srand(time(NULL));
	testSmithy();
	return 0;
}
